<?php
	include ('../config/validacao.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"http://www.w3.org/TR/html4/strict.dtd">
<html lang="pt_BR">
<head>
	<meta charset="utf-8">
	<link rel="icon" type="image/png" href="../images/icone.png">
	<title><?php include('../titulo.php')?></title>
		
		<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="../css/DT_bootstrap.css">
		<link rel="stylesheet" href="../css/index.css"  media="screen"> 
		<script type="text/javascript" charset="utf-8" language="javascript" src="../js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> 
		<script type="text/javascript" charset="utf-8" language="javascript" src="../js/jquery.dataTables.js"></script>
		<script type="text/javascript" charset="utf-8" language="javascript" src="../js/DT_bootstrap_setor.js"></script>
		<script language="Javascript">
			function confirmacao(id) {
				var resposta = confirm("Deseja remover esse registro?");
				if (resposta == true) {
					var dados = 'id='+id;
					window.location.href = "excluir_setor.php?"+dados;
/*					var dados = 'id='+id;  
					$.ajax({  
						type: "POST",  
						url: "excluir_setor.php",  
						data: dados,  
						success: function( data )  
						{  
							alert( data );
							window.location.href = "e_setor.php";
						}  
					});  
*/
				}
			}
		</script>
	</head>
	<body>
		<div id="topo" style="text-align:left;position:absolute;">
			<?php include('../cabecalho.php') ?>
		</div>
		<div class="container" style="margin-top: 0px;text-align:center;">
		<br><br><br>
		<fieldset>
				<legend>Setor</legend>
				<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
				<thead>
					<tr>
						<th>Local</th>
						<th>Setor</th>
						<th>Tag</th>
						<th>Editar</th>
						<th>Excluir</th>
					</tr>
				</thead>
				<tbody>
				<?php
						header ('Content-type: text/html; charset=UTF-8'); 
						include ('../config/conexao.php');
						// mysql_query("SET NAMES 'utf8'");
					 
						// query the database table for zip codes that match 'term'
						$rs = mysql_query('SELECT  `idsetor`, `nomeSetor` , `tag`, `nomeSecretaria` 
											FROM  `setor` ,  `secretaria` 
											WHERE `secretaria_idsecretaria` =  `idsecretaria` ');

						// loop through each zipcode returned and format the response for jQuery
						$data = array();
						if ( $rs && mysql_num_rows($rs) )
						{
							while( $row = mysql_fetch_array($rs) )
							{
								echo "<tr class='odd gradeX'>";
								echo "<td>".utf8_encode($row['nomeSecretaria'])."</td>";
								echo "<td>".utf8_encode($row['nomeSetor'])."</td>";
								echo "<td>".utf8_encode($row['tag'])."</td>";
								echo "<td class='center'><a href='editar_setor.php?id=".$row['idsetor']."'><img src='../images/edit.png'/></a></td>";
								echo "<td class='center'><a href='javascript:void()' onclick='confirmacao(".$row['idsetor'].");'><img src='../images/trash.png'/></a></td>";
//echo "<td>eh tenso</td>";
								echo "</tr>";
							}
						}
					?>
				</tbody>
			</table>
		</div>
		</fieldset>
	</body>
</html>
